package com.xbts.screen.controller.workshop;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.ICharactersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文字车间Controller
 */
@Api(tags = "文字车间")
@RestController
@RequestMapping("/characters")
public class CharactersController extends BaseController {


    @Autowired
    private ICharactersService charactersService;

    /**
     * 实时达成率
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:characters:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = charactersService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:characters:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = charactersService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:characters:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = charactersService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:characters:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = charactersService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:characters:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = charactersService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:characters:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = charactersService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:characters:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = charactersService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:characters:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = charactersService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * PCS合格率
     */
    @ApiOperation("PCS合格率")
    @RequiresPermissions("workshop:characters:PCSPassRate")
    @GetMapping("/PCS/passRate")
    public AjaxResult PCSPassRate(){
        PassRateVO vo = charactersService.PCSPassRate();
        return success(vo);
    }
    /**
     * PCS不良统计
     */
    @RequiresPermissions("workshop:characters:PCSBadStatistics")
    @GetMapping("/PCS/badStatistics")
    public AjaxResult PCSBadStatistics(){
        List<BasePieChartResult> resultList = charactersService.PCSBadStatistics();
        return success(resultList);
    }
    /**
     * PCS合格率趋势
     */
    @ApiOperation("PCS合格率趋势")
    @RequiresPermissions("workshop:characters:PCSPassRateTrend")
    @GetMapping("/PCS/passRateTrend")
    public AjaxResult PCSPassRateTrend(){
        BaseHistogramResult result = charactersService.PCSPassRateTrend();
        return success(result);
    }
    /**
     * 不良统计
     */
    @ApiOperation("不良统计")
    @RequiresPermissions("workshop:characters:badStatistics")
    @GetMapping("/badStatistics")
    public AjaxResult badStatistics(){
        List<BasePieChartResult> resultList = charactersService.badStatistics();
        return success(resultList);
    }
    /**
     * 首件合格率
     */
    @ApiOperation("首件合格率")
    @RequiresPermissions("workshop:characters:firstArticlePassRate")
    @GetMapping("/firstArticlePassRate")
    public AjaxResult firstArticlePassRate(){
        ScrapRateVO vo = charactersService.firstArticlePassRate();
        return success(vo);
    }
    /**
     * 料号批次合格率记录
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:characters:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = charactersService.passRateRecord();
        return success(resultList);
    }

}
